package com.tjetc.mapper;

import com.tjetc.domain.RankRecord;
import com.tjetc.vo.HospitalBuildingInfoVo;
import com.tjetc.vo.RankClinic;
import com.tjetc.vo.RankVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface RankRecordMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(RankRecord record);

    int insertSelective(RankRecord record);

    RankRecord selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(RankRecord record);

    int updateByPrimaryKey(RankRecord record);

    List<RankVo> getRankVos(Integer id);



    HospitalBuildingInfoVo getHospitalBuildingWithRoom(
            @Param("pid") Integer pid,
            @Param("hospitalName") String hospitalName,
            @Param("sid")Integer sid
    );
    //根据就诊人id 和 医院名称 获取排名信息
    List<RankRecord> getMyRankRecord(@Param("pid") Integer pid,
                               @Param("hospitalName") String hospitalName);
    //查询当天所有的叫号(同一个诊室),筛选出号码最大且state属性是3的
    RankRecord   selectMaxOrderByScheduleIdAndState(@Param("scheduleId") Integer scheduleId);



    Integer selectShuangYueNum(Integer pid);

    RankRecord selectBySidAndPid(@Param("scheduleId") Integer scheduleId, @Param("pid") Integer pid);

    RankRecord selectByIdWithScheduling(Integer rankId);

    Integer selectCancelCountByDateAndPid(@Param("date") String date, @Param("pid") Integer pid);

    int cancelRank(Integer rankId);

    List<RankRecord> getReportByRankId(@Param("pid") Integer pid);

    List<RankClinic> getRankCount(String hospitalName);

    @Select("select count(*) from rank_record where schedule_id = #{id} ")
    Integer selectCountBySid(Integer id);

    List<RankRecord> getRankRecordsBySid(Integer sid);

    Integer updateOldHao(@Param("currentHao") Integer currentHao,@Param("sid") Integer sid);

    Integer updateNewHaoByRid(Integer rid);

    Integer updateZhenDuanByRid(Integer rid);

    RankRecord selectHao(Integer sid);

    RankRecord selectZhen(Integer sid);

    RankRecord selectBySidAndOrder(@Param("sid") Integer sid,@Param("currentZhen") Integer currentZhen);

    List<RankRecord> getByNameAndIdCard(@Param("idCard") String idCard, @Param("name") String name);
    @Select("SELECT MAX(`order`) FROM rank_record WHERE schedule_id=#{scheduleId} ")
    Integer selectMaxOrderByScheduleId(Integer scheduleId);

    @Select("SELECT * FROM rank_record")
    List<RankRecord> getAll();
}